import configparser
import os

config_path = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "config", "config.ini")


class IniFiles:
    def __init__(self):
        self.config_path = config_path

    def read_ini(self):
        """读取 config.ini 配置文件内容，返回数据"""
        config = configparser.ConfigParser()
        config.read(self.config_path, encoding='utf8')
        return config


IniFiles = IniFiles()

if __name__ == '__main__':
    section = IniFiles.read_ini()['host']
    print(f'测试打印config.ini 配置文件内容host section>>>{section}')
    api_url = IniFiles.read_ini()['host']['api_url']
    print(f'测试打印config.ini 配置文件内容api_url>>>{api_url}')

"""
.ini 文件格式

[Section1]
Key1 = Value1
Key2 = Value2

[Section2]
Key3 = Value3
"""
